<?php

namespace App\Http\Controllers\Admin\Orders;

use App\Http\Controllers\Admin\Orders\Api\AdminOrdersApi;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

/**
 * @descr   作用:后台订单展示
 * @author  liuguansheng
 * Class AdminOrdersController
 * @package App\Http\Controllers\Admin\Orders
 */
class AdminOrdersController extends Controller
{
	protected $AdminOrdersApi;//购物车Api实例化对象

	public function __construct()
	{
		$this->AdminOrdersApi = new AdminOrdersApi();
	}

	/**
	 * 调用订单展示API方法,查询订单并展示
	 * @return $this|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
	 */
	public function index()
	{
		$res = $this->AdminOrdersApi->showOrders();
		if ( $res ) {
		    return view('Admin.Orders.orders-list')->with('data',$res);
		} else {
			return view('Admin.Orders.orders-list');
		}
    }

	public function showDetail($oid)
	{
		$res = $this->AdminOrdersApi->showDetails($oid);
		if ( $res ) {
		    return view('Admin.Orders.orders-detail')->with('data',$res);
		}
    }

	public function editOrders($oid)
	{
		$res = $this->AdminOrdersApi->editOrders($oid);
		if ( $res ) {
			return view('Admin.Orders.orders-edit')->with('data',$res);
		}
    }

	public function doEditOrders(Request $request)
	{
		$id = $request->id;
		$state = $request->state;
		$res = $this->AdminOrdersApi->doedit($id,$state);

		if ( $res ) {
		    return redirect('/admin/orders/')->with('mess','修改成功');
		}
    }

}
